package com.leetcode.lccup;

import com.leetcode.common.TreeNode;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/4/16 15:35
 */
public class LCCUP3二叉搜索树染色 {

    private static final int N = (int) (1e9 + 10);
    private static SegmentTree tr = new SegmentTree(0, N, 0);
    private static int ans = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int m = Integer.parseInt(reader.readLine());
        int[][] ops = new int[m][3];
        for (int i = 0; i < m; i++) {
            String[] ss = reader.readLine().split(" ");
            ops[i] = new int[]{Integer.parseInt(ss[0]), Integer.parseInt(ss[1]), Integer.parseInt(ss[2])};
        }
        int q = Integer.parseInt(reader.readLine());
        int[] que = new int[q];
        String[] ss = reader.readLine().split(" ");
        for (int i = 0; i < q; i++) que[i] = Integer.parseInt(ss[i]);
        writer.write(getNumber(que, ops) + "\n");
        writer.flush();
    }

//    public static int getNumber(TreeNode root, int[][] ops) {
    public static int getNumber(int[] que, int[][] ops) {
        for (int[] op : ops) {
            int l = op[1], r = op[2];
            if (op[0] == 0) modify(tr, l, r, 0);
            else modify(tr, l, r, 1);
        }
//        dfs(root);
        for (int i = 0; i < que.length; i++) ans += query(tr, que[i], que[i]);
        return ans;
    }

    private static void dfs(TreeNode u) {
        if (u == null) return;
        ans += query(tr, u.val, u.val);
        dfs(u.left);
        dfs(u.right);
    }

    private static int query(SegmentTree tr, int l, int r) {
        if (l <= tr.l && r >= tr.r) return tr.redc;
        pushdown(tr);
        int mid = tr.l + tr.r >> 1, res = 0;
        if (l <= mid) res += query(tr.left(), l, r);
        if (r > mid) res += query(tr.right(), l, r);
        return res;
    }

    private static void pushdown(SegmentTree tr) {
        if (tr.lazy) {
            tr.left().color = tr.right().color = tr.color;
            tr.left().lazy = tr.right().lazy = tr.lazy;
            tr.left().update();
            tr.right().update();
            tr.lazy = false;
        }
    }

    private static void pushup(SegmentTree tr) {
        tr.redc = tr.left().redc + tr.right().redc;
    }

    private static void modify(SegmentTree tr, int l, int r, int color) {
        if (l <= tr.l && r >= tr.r) {
            tr.color = color;
            tr.lazy = true;
            tr.update();
        } else {
            pushdown(tr);
            int mid = tr.l + tr.r >> 1;
            if (l <= mid) modify(tr.left(), l, r, color);
            if (r > mid) modify(tr.right(), l, r, color);
            pushup(tr);
        }
    }

    private static class SegmentTree {
        private int l, r, redc, color;
        private boolean lazy;
        private SegmentTree lc, rc;

        public SegmentTree(int l, int r, int color) {
            this.l = l;
            this.r = r;
            this.color = color;
            update();
        }

        public void update() {
            if (color == 1) redc = r - l + 1;
            else if (color == 0) redc = 0;
        }

        public SegmentTree left() {
            if (lc == null) {
                int mid = l + r >> 1;
                lc = new SegmentTree(l, mid, color);
            }
            return lc;
        }

        public SegmentTree right() {
            if (rc == null) {
                int mid = l + r >> 1;
                rc = new SegmentTree(mid + 1, r, color);
            }
            return rc;
        }
    }
}
